 /*@Author S.Genikhov*
  Creation Date 19/06/2010
  Last modifed  23/08/2010
  @St_Schelduler run function of type func with some repeatablity provided by user*/
#ifndef ST_SCHELDULER_INCLUDED
#define ST_SCHELDULER_INCLUDED

#define INOUT
#include <stdio.h>

typedef enum err_Sch{
SCH_SCHEDULLER_OK                  = 0,
SCH_READYQ_INSERTION_PROBLEMS      = 4,
SCH_GET_NEXT_TASK_PROBLEMS         = 10,
SCH_TASK_CREATION_PROBLEMS         = 30,
SCH_NO_TASKS_IN_SCHEDULLER         = 70
} err_Sch;



typedef struct SchScheduller_t SchSched;

/*Scheduller initillization,in case of fails returns 0,
possible failure memory allocation fails*/
SchSched* SchInit(void);


typedef void (*Taskfunc)(void* );
/*Inserting function to Scheludler  mperiond in msec, minimum 1 max 10000*/
err_Sch SchInsertTask(SchSched* _Sch,Taskfunc _workfunc,size_t _mperiod,void* _userdata );

/*Makes the Scheduller loop ones*/
err_Sch SchRunOnce(SchSched* _Sch);

/*Performs the one Scheduller loop non-stop*/
err_Sch  SchSchedRunForever(SchSched* _Sch);

/*returns time to next task in milli seconds,
If task is late       - returns 0,
If sheduller is empty - returns */
size_t SchGetTimeToNextTask(SchSched* _Sch);

/*Destroy of Schelduler*/
void SchDestroy(SchSched* _Sch);
#endif /* ST_SCHELDULER_INCLUDED*/
